// pages/tabBar/mine/components/function.js
const app = getApp()
const util = require('../../../../utils/util.js')
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    toFavorite(e){
      if(util.isNull(app.globalData.token)){
        wx.navigateTo({
          url: '/pages/login/index',
        })
      }else{
        wx.navigateTo({
          url: '/pages/member/favorite/index?id=' + e.currentTarget.dataset.index
        })
      }
    },
    evaluateClick(){
      if(util.isNull(app.globalData.token)){
        wx.navigateTo({
          url: '/pages/login/index',
        })
      }else{
        wx.navigateTo({
          url: '/pages/member/evaluate/index',
        })
      }
    },
    toSetting(){
      wx.navigateTo({
        url: '/pages/member/setting/index',
      })
    },
    couponClick(){
      if(util.isNull(app.globalData.token)){
        wx.navigateTo({
          url: '/pages/login/index',
        })
      }else{
        wx.navigateTo({
          url: '/pages/member/coupon/index',
        })
      }
    },
    contactClick(){
      wx.navigateTo({
        url: '/pages/contact/index',
      })
    },
    toOrder: function() {
      if(util.isNull(app.globalData.token)){
        wx.navigateTo({
          url: '/pages/login/index',
        })
      }else{
        getApp().globalData.switchTabIndex = 3
        wx.switchTab({
          url: '/pages/tabBar/shoppingCart/shoppingCart',
        })
      }
    },
    toAddress:function(){
      if(util.isNull(app.globalData.token)){
        wx.navigateTo({
          url: '/pages/login/index',
        })
      }else{
        wx.navigateTo({
          url:'/pages/member/address/address',
        })
      }
    }
  }
})
